package com.guxingke.typecho4j.widget.provider.content;

import java.util.List;

import javax.servlet.ServletContext;

import com.guxingke.typecho4j.Typecho4j;
import com.guxingke.typecho4j.jfinal.model.Content;
import com.guxingke.typecho4j.widget.WidgetProvider;
import com.guxingke.typecho4j.widget.provider.ContentBaseWidget;
import com.jfinal.core.Controller;

/**
 * 前台首页header独立也导航menu组件
 * 
 * @author guxingke
 *
 */
public class FrontHeaderMenuWidget extends ContentBaseWidget implements
		WidgetProvider {
	private List<Content> pages;

	/**
	 * applicationContext,便于向application作用域中添加数据
	 * */
	private ServletContext servletContext;

	@Override
	public boolean init() {
		initLogger();

		this.servletContext = Typecho4j.typecho4j().getServletContext();

		pages = getPages();
		servletContext.setAttribute("pages", pages);

		return true;
	}

	@Override
	public void excute(Controller controller) {
	}

	@Override
	public void refresh() {
		pages = getPages();
	}
}
